<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工作提醒列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <div class="btn-group " style="margin: 0px auto;display: table;" role="group">
                <button type="button" class="top-link btn btn-sm btn-primary">农事</button>
                <button type="button" class="top-link btn-sm btn-white">牛奶入库</button>
                <button type="button" class="top-link btn-sm btn-white">牛奶仓储</button>
                <button type="button" class="top-link btn-sm btn-white">牛奶出库</button>
            </div>

        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <div class="btn-group-sm " id="toolbar1" role="group">
                <h3 class="inline">工作内容：</h3>
            </div>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
    <div class="bottom-btns"></div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncWorkNotice:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncWorkNotice:remove')}]];

    var disinfectionFlag = [[${@permission.hasPermi('system:ncGoods:disinfection')}]];
    var feedFlag = [[${@permission.hasPermi('system:ncGoods:feed')}]];
    var milkFlag = [[${@permission.hasPermi('system:ncGoods:milk')}]];
    var prefix = ctx + "system/ncWorkNotice";

    $(function () {
        var options = {
            url: prefix + "/list?noticeType=" + 1,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "工作提醒",
            showExport: false,
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            columns: [
                /*{
                checkbox: true
            },*/
                /*{
                    field: 'workNoticeId',
                    title: '序号',
                },*/
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'lastTime',
                    title: '上次执行时间',
                    sortable: true
                },
                {
                    field: 'workType',
                    title: '工作名称', //： 1：消毒 2：饲喂 3：挤奶
                    formatter: function (value, row, index) {
                        if (value == 1) {
                            return "消毒";
                        } else if (value == 2) {
                            return "喂料";
                        } else if (value == 3) {
                            return "挤奶";
                        } else {
                            return '--';
                        }
                    }
                },
                /*{
                    field: 'worckNoticeName',
                    title: '工作名称',
                    sortable: true
                },*/
                {
                    field: 'content',
                    title: '工作内容',
                    sortable: true
                },
                {
                    field: 'time',
                    title: '时间点',
                    sortable: true
                },

                /*{
                    field : 'noticeType',
                    title : '提醒类型： 1:牛舍 2：鸡舍',
                    sortable: true
                },

                {
                    field : 'cycleDays',
                    title : '循环周期(天)',
                    sortable: true
                },
                {
                    field : 'createTime',
                    title : '日期',
                    sortable: true
                },
                {
                    field : 'createBy',
                    title : '创建人',
                    sortable: true
                },*/
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        /* actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.workNoticeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.workNoticeId + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        if (row.workType == 1) {
                            actions.push('&nbsp;<a class="btn btn-info btn-xs ' + disinfectionFlag + '" href="javascript:void(0)" onclick="disinfection(\'' + row.workNoticeId + '\')"><i class="fa fa-key"></i>消毒</a>');
                        } else if (row.workType == 2) {
                            actions.push('&nbsp;<a class="btn btn-info btn-xs ' + feedFlag + '" href="javascript:void(0)" onclick="feed(\'' + row.workNoticeId + '\')"><i class="fa fa-key"></i>饲喂</a>');
                        } else if (row.workType == 3) {
                            actions.push('&nbsp;<a class="btn btn-info btn-xs ' + milkFlag + '" href="javascript:void(0)" onclick="milk(\'' + row.workNoticeId + '\')"><i class="fa fa-key"></i>挤奶</a>');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        $.table.refresh();

        var btns = [
            {
                name: "产奶记录",
                url: ctx + 'system/ncCowsMilk',
                id: 'Milk-work'
            },
            {
                name: "主饲料",
                url: ctx + 'system/ncFeed?feedType=1',
                id: 'Feed-work'
            },
            {
                name: "辅饲料",
                url: ctx + 'system/ncFeed2?feedType=2',
                id: 'Feed2-work'
            },
            {
                name: "消毒记录",
                url: ctx + 'system/ncCowsDisinfection?managerType=2',
                id: 'Disinfection-work'
            },
            {
                name: "兽医请求",
                url: ctx + 'system/ncZhenliaoLogs/cow/askZhenLiaoList   ',
                id: 'Zhenliao-work'
            },
            {
                name: "所有诊疗记录",
                url: ctx + 'system/ncZhenliaoLogs/cow/allZhenliao   ',
                id: 'Zhenliao-all'
            },
            {
                name: "诊疗单",
                url: ctx + 'system/ncOrder?orderType=14',
                id: 'Medical-work'
            },
            {
                name: "档案管理",
                url: ctx + 'system/ncCowsFiles',
                id: 'Depot-work'
            },
            {
                name: '工作记录',
                url: ctx + 'system/ncNormalWorks?workType=8',
                id: 'normal-work'
            },
            {
                name: '所有出库',
                url: ctx + 'system/ncOutputMilk/ncOutputMilkAll',
                id: 'ncOutputMilkAll'
            }

        ]
        addBtns(btns);
    });

    /* 消毒操作 */
    function disinfection(workNoticeId) {
        var url = prefix + '/disinfection/' + workNoticeId;
        $.modal.open("消毒", url)
    }

    /*挤奶操作*/
    function milk(workNoticeId) {
        var url = prefix + '/milk/'+workNoticeId;
        $.modal.open("挤奶", url)

    }

    /*饲喂操作 feed*/
    function feed(workNoticeId) {
        var url = prefix + '/feed/'+workNoticeId;
        $.modal.open("饲喂", url)

    }

    /*牛奶入库*/
    $('.top-link').click(function () {
        var index = $(this).index();
        switch (index) {
            case 0:
                window.location.reload();
                return;
            case 1:
                window.location.href = ctx + 'system/ncInputMilk';
                return;
            case 2:
                window.location.href = ctx +'system/ncInputMilkStorage';
                return;
            case 3:
                window.location.href = ctx +'system/ncOutputMilk';
                return;
        }
    })
    setTitle("牛舍管理-农事",false)


</script>
</body>
</html>